import Sequelize, { Model } from 'sequelize';

export default class Config extends Model {
  static init({ db }) {
    super.init({
      // attributes
      title: { type: Sequelize.STRING, allowNull: false, validate: { len: [1, 30] } },
      // timestamp
      createdAt: { type: Sequelize.DATE, field: 'created_at' },
      updatedAt: { type: Sequelize.DATE, field: 'updated_at' },
      deletedAt: { type: Sequelize.DATE, field: 'deleted_at' },
    }, {
      // configuration
      modelName: 'Config',
      sequelize: db,
      timestamps: true,
      paranoid: true,
      // updatedAt: false,
      // underscored: true,
      freezeTableName: true,
      tableName: 'config',
    });

    return this;
  }
}
